package com.codeoss.framework.view.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.codeoss.framework.context.YunContext;
import com.codeoss.framework.expression.Expression;
import com.codeoss.framework.expression.IScriptServiceStore;
import com.codeoss.framework.view.component.Component;
import com.codeoss.framework.view.component.ShortcutMenu;
import com.codeoss.framework.view.service.IShortcutMenuComponentService;

@Service("shortcutmenuComponentService")
public class ShortcutMenuComponentService extends ComponentService implements IShortcutMenuComponentService {
    @Autowired
    private IScriptServiceStore scriptServiceStore;
    
	@Override
	public List<Map<String, String>> getMenuList(YunContext yunContext, Component component) {
		// TODO Auto-generated method stub
		ShortcutMenu shortcutMenu=(ShortcutMenu)component;
		Expression dataSourceScript=shortcutMenu.getDataSourceScript();
		Map<String,Object> bindingMap=new HashMap<String,Object>();
		List<Map<String,String>> dataList=new ArrayList<Map<String,String>>();
		bindingMap.put("shortcutMenuDataSource", dataList);
		scriptServiceStore.getScriptService(dataSourceScript).eval(dataSourceScript.getScript(), bindingMap);
		return dataList;
	}

}
